/*
 * Player.cpp
 *
 *  Created on: Oct 15, 2014
 *      Author: hercules
 */

#include "Player.h"

Player::Player(Shape* shape, Animation* playerAnimation) :
		GameObject(shape) {
	_playerAnimation = playerAnimation;

}
void Player::render(float cameraX, float cameraY) {
	_playerAnimation->render(getShape()->getCenterRef()->getX() - cameraX,
			getShape()->getCenterRef()->getY() - cameraY, true,
			GameArea::getSurface());
}

int Player::update(double dt) {
	if (InputManager::getInstance()->isKeyPressed(SDLK_UP)) {
		_playerAnimation->setCurrentRow(3);
		getShape()->setY(getShape()->getY() - 5);
	}
	if (InputManager::getInstance()->isKeyPressed(SDLK_DOWN)) {
		_playerAnimation->setCurrentRow(0);
		getShape()->setY(getShape()->getY() + 5);
	}
	if (InputManager::getInstance()->isKeyPressed(SDLK_LEFT)) {
		_playerAnimation->setCurrentRow(1);
		getShape()->setX(getShape()->getX() - 5);
	}
	if (InputManager::getInstance()->isKeyPressed(SDLK_RIGHT)) {
		_playerAnimation->setCurrentRow(2);
		getShape()->setX(getShape()->getX() + 5);
	}
	_playerAnimation->update(dt);
	return 0;
}

Player::~Player() {
	// TODO Auto-generated destructor stub
}

